import { RouteRecordRaw } from 'vue-router';
import {
  HddOutlined,
  SaveOutlined,
  GatewayOutlined,
  ApartmentOutlined,
  UserOutlined,
  ToolOutlined,
  MessageOutlined,
  FundViewOutlined,
  DeploymentUnitOutlined,
} from '@ant-design/icons-vue';

/**
 * 建议：路由 path 路径与文件夹名称相同，找文件可浏览器地址找，方便定位文件位置
 *
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：        是否超链接菜单，开启外链条件，`1、isLink: 链接地址不为空 2、isIframe:false`
 *      isHide：        是否隐藏此路由
 *      isKeepAlive：   是否缓存组件状态
 *      isAffix：       是否固定在 tagsView 栏上
 *      isIframe：      是否内嵌窗口，开启条件，`1、isIframe:true 2、isLink：链接地址不为空`
 *      roles：         当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 定义动态路由
 * 前端添加路由，请在顶级节点的 `children 数组` 里添加
 * @returns 返回路由菜单数据
 */
export const dynamicRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    name: '布局',
    redirect: '/data-source',
    component: () => import('@/layout/index.vue'),
    children: [
      {
        path: '/data-source',
        name: '数据源管理',
        component: () => import('@/pages/DataSource/index.vue'),
        meta: {
          icon: HddOutlined,
          title: 'DataSource',
          roles: ['sys:user'],
        },
      },
      {
        path: '/entity',
        name: '实体配置',
        redirect: '/entity/dimension',
        meta: {
          icon: GatewayOutlined,
          title: 'entity',
          roles: ['sys:user'],
        },
        children: [
          {
            path: '/entity/dimension',
            name: '维度',
            component: () => import('@/pages/Config/dimension/index.vue'),
            meta: {
              icon: DeploymentUnitOutlined,
              title: 'dimension',
              roles: ['sys:user'],
            },
          },
          {
            path: '/entity/metrics',
            name: '指标',
            component: () => import('@/pages/Config/metrics/index.vue'),
            meta: {
              icon: FundViewOutlined,
              title: 'metrics',
              roles: ['sys:user'],
            },
          },
        ],
      },
      {
        path: '/tools/manage',
        name: '工具管理',
        component: () => import('@/pages/Tools/index.vue'),
        meta: {
          icon: ToolOutlined,
          title: 'tools',
          roles: ['sys:user'],
        },
      },
      {
        path: '/tools/detail',
        name: '工具详情',
        component: () => import('@/pages/Tools/detail.vue'),
        meta: {
          icon: ToolOutlined,
          title: 'tools-detail',
          roles: ['sys:user'],
          isHide: true,
        },
      },
      {
        path: '/case-base/manage',
        name: '案例库管理',
        component: () => import('@/pages/CaseBase/index.vue'),
        meta: {
          icon: SaveOutlined,
          title: 'case-base',
          roles: ['sys:user'],
        },
      },
      {
        path: '/chain-of-thought',
        name: '思维链配置',
        component: () => import('@/pages/Thought/index.vue'),
        meta: {
          icon: ApartmentOutlined,
          title: 'thought',
          roles: ['sys:user'],
        },
      },
      {
        path: '/chat',
        name: '对话',
        component: () => import('@/pages/Chat/index.vue'),
        meta: {
          icon: MessageOutlined,
          title: 'chat',
          roles: ['sys:user'],
        },
      },
      {
        path: '/user/manage',
        name: '用户管理',
        component: () => import('@/pages/User/index.vue'),
        meta: {
          icon: UserOutlined,
          title: 'user',
          roles: ['sys:user'],
        },
      },
    ],
  },
];

/**
 * @description 定义静态路由（默认路由）
 * @returns 返回路由菜单数据
 */
export const staticRoutes = [
  {
    path: '/login',
    name: '登录',
    component: () => import('@/pages/Login/index.vue'),
  },
];

/**
 * 定义404、401界面
 */
export const notFoundAndNoPower = [
  {
    path: '/:path(.*)*',
    name: 'notFound',
    component: () => import('@/pages/Error/index.vue'),
    meta: {
      title: 'message.staticRoutes.notFound',
      isHide: true,
    },
  },
];
